<?php
include('general_include.php');
include('class/json.php');

 
$total_in=0;

if($_REQUEST['Search_from_date_in']!='From'){

	$Search_from_date_in = $_REQUEST['Search_from_date_in'];
}
else{

	$Search_from_date_in = '';
}

if($_REQUEST['Search_to_date_in']!='To'){

	$Search_to_date_in = $_REQUEST['Search_to_date_in'];
}
else{

	$Search_to_date_in = '';
}

if(!empty($Search_from_date_in))
{
	 $searchSql =  $searchSql." AND date_added >= '".$_REQUEST['Search_from_date_in']."'";
}

if(!empty($Search_to_date_in))
{
	  $searchSql =  $searchSql." AND date_added <= '".$_REQUEST['Search_to_date_in']."'";
}

$IncomeSql =  "SELECT * FROM ".TABLEPREFIX."_lesson Where coach_id=".$_SESSION['user_id'].$searchSql; 
$Income=$UserManagerObjAjax->GetRecords("All",$IncomeSql);

for($i=0;$i<count($Income);$i++){
	
	/*$select_status_title="select lesson_status_title from ".TABLEPREFIX."_lesson_status where lesson_status_id=".$Income[$i]['lesson_status_id'];
	$status_title=$UserManagerObjAjax->GetRecords("Row",$select_status_title);*/
	
	if($Income[$i]['lesson_status_id'] == 4){
	
		$SelectCmsArr[$i]['lesson_price_deducted']=$Income[$i]['lesson_price']*(1-($Income[$i]['lesson_commision_admin']/100));
		$total_in=number_format(($total_in + $SelectCmsArr[$i]['lesson_price_deducted']), 2, '.', '');
	}
	
			 
}


echo json_encode(

		array(
		
			'IncomeSql'=> $IncomeSql,
			'total_in' => $total_in
		)
	);			

?>